const { app, BrowserWindow } = require('electron')
const path = require('node:path')

const createWindow = () => {
    const { width, height } = require('electron').screen.getPrimaryDisplay().workAreaSize;
    const win = new BrowserWindow({
        width: width,
        height: height,
        //frame: true,
        // titleBarStyle: 'hidden',
        //autoHideMenuBar: false, //隐藏菜单
        // icon: filePath,
        webPreferences: {
            nodeIntegration: true, // 使渲染进程拥有node环境
            //关闭web权限检查，允许跨域
            webSecurity: false,
            // Use pluginOptions.nodeIntegration, leave this alone
            // See nklayman.github.io/vue-cli-plugin-electron-builder/guide/security.html#node-integration for more info
            nodeIntegration: process.env.ELECTRON_NODE_INTEGRATION,
            contextIsolation: !process.env.ELECTRON_NODE_INTEGRATION,
        },
    })
    win.webContents.openDevTools()
    win.loadFile('gen.html')
    win.webContents.on('did-finish-load', () => {
        // console.log('versions', win)
    });
    // const info = `本应用÷正在使用 Chrome (v${win.versions.chrome()}), Node.js (v${win.versions.node()}), 和 Electron (v${win.versions.electron()})`
    // const info = `本应用正在使用 Chrome (v${win.versions})})`
    // console.log('versions', win.versions)
}

app.whenReady().then(() => {
    createWindow()
})